/**
 * 
 */
package uno.net;

import java.io.Serializable;

/**
 * 
 * Rappresenta l'identificativo univoco di un giocatore
 * nella partita.
 * 
 * @author mattia
 *
 */
public class UnoPlayerID implements Serializable{

	private static final long serialVersionUID = -3460374600949553267L;

	/**
	 * formato da ip:port
	 * */
	private String address;
	private String name;
	
	public UnoPlayerID(String address, String name) {
		this.address = address;
		this.name = name;		
	}
	
	/**
	 * Address = ip:port
	 * */
	public String getAddress() {
		return address;
	}
	
	public void setAddress(String address) {
		this.address = address;
	}
	
	public String getName() {
		return name;
	}
	
	public void setName(String name) {
		this.name = name;
	}

	public String toString() {
		return "<" + getAddress() + ", " + getName() + ">";	
	}

	@Override
	public boolean equals(Object obj) {
		boolean flag = false;

		if(obj instanceof UnoPlayerID){
			UnoPlayerID tmpObj = (UnoPlayerID)obj;
			if(tmpObj.getAddress().equals(getAddress()) && tmpObj.getName().equals(getName()))
				flag = true;
				
		}
		
		return flag;
	}

	
	
}
